package com.itheima.service;

import com.itheima.mapper.UserMapper;
import com.itheima.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class UserService {

//    @Autowired
    @Autowired(required = false)
    private UserMapper userMapper;
//  查询
    public User queryById(Long id){
        return userMapper.selectByPrimaryKey(id);
    }
    @Transactional
    public void saveUser(User user){
        System.out.println("添加用户");
//        选择性新增
        userMapper.insertSelective(user);
    }
}
